import { submitBooking } from "./api.js";

document.addEventListener('DOMContentLoaded', function () {
    document.querySelector('.book-btn').addEventListener('click', async () => {
        const checkIn = document.querySelector('.checkin-date').value;
        const checkOut = document.querySelector('.checkout-date').value;
        const roomType = document.querySelector('select').value;

        const bookingData = {
            checkIn,
            checkOut,
            roomType
        };

        try {
            const result = await submitBooking(bookingData);
            alert('预订成功！');
        } catch (error) {
            console.error(error);
            alert('提交失败，请稍后再试');
        }
    });
});
